package com.hangxiang.approval.controller;

import com.hangxiang.approval.common.*;
import com.hangxiang.approval.entity.GroupManager;
import com.hangxiang.approval.service.GroupManagerService;
import com.hangxiang.approval.vo.GroupManagerVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * (Groupmanager)表控制层
 *
 * @author makejava
 * @since 2020-11-23 18:06:31
 */
@RestController
@RequestMapping("groupManager")
@Api(tags = "用户部门相关功能")
public class GroupManagerController {
    /**
     * 服务对象
     */
    @Resource
    private GroupManagerService groupmanagerService;

    /**
     * 通过主键查询单条数据
     *
     * @param common 主键
     * @return 单条数据
     */
    @PostMapping("selectOne")
    @ApiOperation(value = "通过主键查询单条数据")
    @ResponseBody
    public ResultBean selectOne(@RequestBody @Validated IntegerCommon common) {
        return ResultBean.success(groupmanagerService.queryById(common));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param common 主键
     * @return 单条数据
     */
    @PostMapping("selectInfoByUserId")
    @ApiOperation(value = "根据用户Id查询部门信息")
    @ResponseBody
    public ResultBean selectInfoByUserId(@RequestBody @Validated GroupManagerCommon common) {
        GroupManagerVo managerVo=groupmanagerService.selectInfoByUserId(common);
        return ResultBean.success(managerVo);
    }

//    /**
//     * 通过主键查询单条数据
//     *
//     * @return 单条数据
//     */
//    @PostMapping("selectAllInfo")
//    @ApiOperation(value = "查询所有的部门和所有的人")
//    @ResponseBody
//    public ResultBean selectAllInfo() {
//        List<GroupManagerVo> managerVoList=groupmanagerService.selectAllInfo();
//        return ResultBean.success(managerVoList);
//    }



    /**
     * 新增数据
     *
     * @param groupmanagerInsertCommon 实例对象
     * @return 实例对象
     */
    @PostMapping("insertGroupmanager")
    @ApiOperation(value = "添加数据")
    @ResponseBody
    public ResultBean insertGroupManger(@RequestBody @Validated GroupManagerInsertCommon groupmanagerInsertCommon) {
        return ResultBean.success(groupmanagerService.insertGroupManager(groupmanagerInsertCommon));
    }

    /**
     * 新增数据
     *
     * @param groupmanagerUpdateCommon 实例对象
     * @return 实例对象
     */
    @PostMapping("updateGroupmanager")
    @ApiOperation(value = "修改isDeleted就是删除")
    @ResponseBody
    public ResultBean update(@RequestBody @Validated GroupManagerUpdateCommon groupmanagerUpdateCommon) {
        return ResultBean.success(groupmanagerService.updateGroupmanager(groupmanagerUpdateCommon));
    }

    @PostMapping("selectDepartment")
    @ApiOperation(value = "查询所有部门")
    @ResponseBody
    public ResultBean selectDepartment(){
        return ResultBean.success(groupmanagerService.selectDepartment());
    }

    @PostMapping("selectDepartmentUser")
    @ApiOperation(value = "部门id查询部门人员")
    @ResponseBody
    public ResultBean selectDepartmentUser(@RequestBody @Validated IntegerCommon common){
        return ResultBean.success(groupmanagerService.selectDepartmentUser(common));
    }





}